<template>
  <div class="bread-content">
    <div :class="['bread-list', {'back': breadList.length > 0}]">
      <!-- <span v-if="breadList.length > 0" :class="{'bread-click': breadList.length > 0}" @click="pageChange([])">&lt;返回｜</span> -->
      <span>线索管理平台</span>
      <!-- <span> > <span :class="{'bread-click': breadList.length > 0}" @click="pageChangeItem(breadList[0], 0)">{{modelName}}</span></span> -->
      <span v-for="(item, index) in breadList" :key="item.name"> > <span :class="{'bread-click': breadList.length > 1 && index < breadList.length - 1}" @click="pageChangeItem(item, index)">{{item.name}}</span></span>
    </div>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex';
  export default {
    name: 'breadList',
    components: {
    },
    props: {
      modelName: {
        type: String,
        default: '任务管理'
      },
      breadList: {
        type: Array,
        default: []
      },
    },
    data() {
      return {
      }
    },
    mounted() {
    },
    methods: {
      // 切换
      pageChangeItem(item, itemIndex) {
        if(this.breadList.length > 0 && itemIndex < this.breadList.length - 1) {
          let index = window.location.href.indexOf('?');
          if(index >= 0) {
            let urlData = window.location.href.substr(index + 1);
            this.$router.push({path:'/' + item.modelName + '?' + urlData})
          }
          else {
            this.$router.push({path:'/' + item.modelName})
          }
        }
      }
    },
    computed: {
      ...mapGetters({
        userInfo: "getUserInfo"
      })
    }
  }
</script>

<style scoped lang="scss">
  .bread-content {
    width: 100%;
    height: 32px;
    background: #F0F2F5
  }
</style>
